package com.hzjh.h5mall.http

import com.hzjh.base.ext.data.UserDataBean
import com.hzjh.base.http.ApiClient
import com.hzjh.base.http.BaseResponse
import com.hzjh.h5mall.BuildConfig
import com.hzjh.h5mall.bean.UpFileResBean
import com.hzjh.h5mall.bean.register.MnemonicWordBean
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.Headers
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part

interface MallApi {
    //注册获取邮箱验证码
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/login/email/captcha")
    suspend fun reqEmailCaptcha(@Body request: RequestBody): BaseResponse<String>
    //注册邮箱
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/login/register/email")
    suspend fun reqEmailRegister(@Body request: RequestBody): BaseResponse<UserDataBean>
    //邮箱登录
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/login/email")
    suspend fun reqEmailLogin(@Body request: RequestBody): BaseResponse<UserDataBean>
    //忘记密码获取验证码
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/login/email/forget/password")
    suspend fun reqForgetEmailCaptcha(@Body request: RequestBody): BaseResponse<String>
    //重置密码
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/login/email/reset/password")
    suspend fun reqResetPassword(@Body request: RequestBody): BaseResponse<String>
    //图片上传
    @POST("api/front/upload/image?model=user&pid=10")
    @Multipart
    suspend fun uploadImage(@Part multipart: MultipartBody.Part): BaseResponse<UpFileResBean>

    //获取助记词
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/login/getMetamaskKey")
    suspend fun reqCreateMnemonic(@Body request: RequestBody): BaseResponse<ArrayList<MnemonicWordBean>>

    //校验助记词
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/login/verifyMetamaskLogin")
    suspend fun reqVerifyMetamaskLogin(@Body request: RequestBody): BaseResponse<UserDataBean>

    //助记词找回密码
    @Headers("Content-Type: application/json;charset=UTF-8")
    @POST("api/front/login/srps/reset/password")
    suspend fun reqResetPasswordBySrp(@Body request: RequestBody): BaseResponse<Any>

    //图片上传
    @POST("api/front/upload/image?model=maintain&pid=0")
    @Multipart
    suspend fun uploadCommImage(@Part multipart: MultipartBody.Part): BaseResponse<UpFileResBean>

    companion object {
        private val api: MallApi by lazy {
            ApiClient.create(BuildConfig.apiHost,MallApi::class.java)
        }
        fun create(): MallApi {
            return api
        }
    }
}